$.fn.extend({
  hlinputSelect: function (data, obj) {
    var that = {}
    that.el = $(this)
    that.data = data || []
    that.obj = obj || {}
    that.initList = function () {
      var htmlStr = '<ul>'
      $.each(that.data, function (index, item) {
        htmlStr += '<li data-name=' + item[that.obj.key] + '>' + item[that.obj.value] + '</li>'
      })
      htmlStr += '</ul>'
      that.el.append(htmlStr)
    }
    that.initList()
    that.el.children('input').on('input', function () {
      that.el.children('ul').children('li').remove()
      let html = ''
      that.data.forEach(item => {
        if (item[that.obj.value].toLowerCase().indexOf($(this).val().toLowerCase()) > -1) {
          html += '<li data-name=' + item[that.obj.key] + '>' + item[that.obj.value] + '</li>'
        }
      });
      that.el.children('ul').html(html)
      that.ListEl.show()
    })
    that.ListEl = $(this).children('ul')
    that.el.click(function () {
      if (that.ListEl.is(':hidden')) {
        that.ListEl.show()
        that.el.css({ 'border': '1px solid #EF7836' })
        that.el.children('span').css({
          'border-top': 'none',
          'border-bottom': '6px solid #999999'
        })
      } else {
        that.ListEl.hide()
        that.el.css({ 'border': '1px solid #999999' })
        that.el.children('span').css({
          'border-top': '6px solid #999999',
          'border-bottom': 'none'
        })
      }
    })
    that.ListEl.on('click', '>li', function () {
      resultData[that.obj.name] = $(this).attr('data-name')
      that.el.children('input').val($(this).html())
    })
  }
})
let resultData = {}
let data = [
  { id: 1, title: 'web-7258' },
  { id: 2, title: 'WEB前端梦之蓝' },
  { id: 3, title: 'helang.love@qq.com' },
  { id: 4, title: 'jQuery之美' },
  { id: 5, title: 'aaa' },
  { id: 6, title: 'bbb' },
  { id: 7, title: 'ccc' },
  { id: 8, title: 'dd' },
  { id: 9, title: 'eeee' },
  { id: 10, title: 'ffff' },
]
let objAttr = {
  name: 'name',
  key: 'id',
  value: 'title'
}
$('#stlect_1').hlinputSelect(data, objAttr)
$('#button').on('click', function () {
  console.log(resultData)
})